//=============================================================================
// Warpblade - really mean melee-weapon to cut bread and vegetables.
//=============================================================================
class TFWBGun extends TFWeapon;

var Vector EndEffect;
var TFWBlade blade;
var TFWBladeGlow glow;

replication
{
//    reliable if(Role<Role_Authority)
//        blade,glow;
    reliable if(Role==Role_Authority)
        ClientDestroy;
}

simulated function ClientDestroy()
{
    if (blade != None)
        blade.Destroy();
    if (glow != None)
        glow.Destroy();
}

function Destroyed()
{
    if (blade != None)
        blade.Destroy();
    if (glow != None)
        glow.Destroy();
    ClientDestroy();

    if(tfwbshiftfire(firemode[1]).bShifted)
    {
        tfwbshiftfire(firemode[1]).bShifted=false;
        instigator.Controller.GotoState('PlayerWalking');
        if(tfpri(instigator.PlayerReplicationInfo)!=none) tfpri(instigator.PlayerReplicationInfo).Shifted=false;
        Instigator.AmbientSound=none;
        if(tfwbshiftfire(firemode[1]).cloud!=none) tfwbshiftfire(firemode[1]).cloud.mRegen=false;
        if(glow!=none) glow.Destroy();
    }

    super.Destroyed();
}


simulated function bool HasAmmo()
{
    return true;
}

function PrebeginPlay()
{
	Super.PreBeginPlay();
}

simulated event ClientStopFire(int Mode)
{
    if (Role < ROLE_Authority)
    {
        StopFire(Mode);
    }
    ServerStopFire(Mode);
}

function float SuggestAttackStyle()
{
    return 0.8;
}

function float SuggestDefenseStyle()
{
    return -0.8;
}

simulated event RenderOverlays( Canvas Canvas )
{
	local float tileScaleX, tileScaleY;

	if ( tfwbshiftfire(firemode[1]).bShifted )
    {
		tileScaleX = Canvas.SizeX / 640.0f;
		tileScaleY = Canvas.SizeY / 480.0f;

        Canvas.DrawColor.R = 255;
		Canvas.DrawColor.G = 255;
		Canvas.DrawColor.B = 255;
		Canvas.DrawColor.A = 255;

        Canvas.Style = ERenderStyle.STY_Normal;
		Canvas.SetPos(0,0);
        Canvas.DrawTile( Material'TFMedia.TFWBSightFB', Canvas.SizeX, Canvas.SizeY, 0.0, 0.0, 512, 512 ); // !! hardcoded size
	}
    else
    {
        Super.RenderOverlays(Canvas);
    }
}

function byte BestMode()
{
	return 0;
}

simulated function float ChargeBar()
{
    local float ShiftStartAmmo;

	ShiftStartAmmo=100-AmmoAmount(1);

	return ShiftStartAmmo/100;
}

defaultproperties
{
     FireModeClass(0)=Class'taskforces.TFWBFire'
     FireModeClass(1)=Class'taskforces.TFWBShiftFire'
     PutDownAnim="PutDown"
     SelectSound=Sound'TFMedia.Warpblade.TFWBslct'
     SelectForce="SwitchToLinkGun"
     bShowChargingBar=True
     AIRating=1.000000
     CurrentRating=1.000000
     bDoAmmoRegen=False
     EffectOffset=(X=100.000000,Y=25.000000,Z=-3.000000)
     DisplayFOV=60.000000
     HudColor=(B=200,G=0,R=75)
     SmallViewOffset=(X=19.000000,Y=9.000000,Z=-6.000000)
     CenteredOffsetY=-22.000000
     CenteredRoll=1000
     InventoryGroup=8
     GroupOffset=3
     PickupClass=Class'taskforces.TFWBPickup'
     PlayerViewOffset=(X=-6.000000,Y=3.000000)
     BobDamping=1.575000
     AttachmentClass=Class'taskforces.TFWBAttachment'
     IconMaterial=Texture'HUDContent.Generic.HUD'
     IconCoords=(X1=179,Y1=127,X2=241,Y2=175)
     ItemName="Warpblade"
     Mesh=SkeletalMesh'Weapons.BioRifle_1st'
     DrawScale3D=(Y=0.500000,Z=0.500000)
     Skins(0)=Texture'TFMedia.Warpblade.WBTex0'
     UV2Texture=Shader'XGameShaders.WeaponShaders.WeaponEnvShader'
     SoundPitch=50
     SoundRadius=96.000000
     TransientSoundVolume=1.000000
     TransientSoundRadius=128.000000
     SkillCost=1000
     StationDmgModifier=0.1
}
